#ifndef SCENE3D_H
#define SCENE3D_H

#include "spacecol2d.h"
#include "spacecol3d.h"
#include "treegen2d.h"
#include "treegen3d.h"
#include "treerender.h"
#include "3DAlgo/shadow3d.h"

class Artistic;
class SpaceCol2D;
class Renderer;
class SpaceCol3D;
static int index_count = 0;
class Scene3D
{
public:
    Scene3D(Renderer * rend);
    ~Scene3D();
    void draw(bool id_mode);
    TreeRender *drawer;
    TreeGen3D *tree0;
        Renderer * render;
    void iterate();
    void clear();

    bool shadow, drawAlgo;

    std::vector <TreeGen3D*> forest;
    std::vector <SpaceCol3D*> spaceColForest;
    void addTree(float2 position);
    int selected_tree;
    void generateMarkers();
    void addMarkers(double x, double y, double z);
    void drawMarkers();
    void addMultipleMetamers(bool b);
    void drawPlane(float3 center, float angle, float halfsize);
    void appicalControl(int b);
    void useBH(bool b);
    void iterateAll();
    bool saveScene(QString filename, Camera * camera);
    bool loadScene(QString filename, Camera * camera);
    void updateSelectedTreeBark();
    void treeBarkHelper(BarkGen * bgen, Bud *curBud);

    bool bsave(QString filename, Camera *cam);
    bool bload(QString filename, Camera *cam);

    float3 rectCenter; // center of the rectangle used to specify the plane to draw markers on.

private:
    Shadow3D *shadowGrid3D;
    Block * m_blocks;
    int numBlock;
    int BPR;
    int BPRSQ;
    bool m_addMultiMeta, m_appicalDepth, m_useBH;
    int count;

};

#endif // SCENE3D_H


//TODO: shadow grid resizing, talk to ben
//TODO: that wierd open gl translate in treerender

//TODO: tree selection, when left clicking in interact mode, change selectedIndex, highlight that tree

